from selenium.webdriver.common.by import By
from page.base_page import BasePage


class LoginPage(BasePage):
    url = "/index.php?m=user&a=login"
    name_locator = (By.NAME, "name")
    url=""
    """定位器"""
    username_locator = (By.NAME, "name")
    password_locator = (By.NAME, "password")
    btn_locator = (By.NAME, "submit")

    def input_name(self, name):
        """输入登录用户名"""
        self.find_element(self.name_locator).send_keys(name)

    def input_password(self, password):
        """输入登录密码"""
        self.find_element(self.password_locator).send_keys(password)

    def click_btn(self):
        """点击登录按钮"""
        self.find_element(self.btn_locator).click()

    def login(self, name, password):
        """完整登录流程"""
        self.input_name(name)
    btn_login_locator = (By.NAME, "submit")
    def input_username(self,username):
        """输入用户名"""
        self.send_keys(self.username_locator, username)
    def input_password(self,password):
        """输入密码"""
        self.send_keys(self.password_locator, password)
    def click_login(self):
        """点击登录"""
        self.find_element(self.btn_login_locator).click()
    def login_success(self,username,password):
        """直接登录成功"""
        self.input_username(username)
        self.input_password(password)
        self.click_btn()
